package com.java.action;

import java.util.List;

import com.java.service.IDeptService;
import com.opensymphony.xwork2.ActionSupport;
import com.training.pojo.chengshu.UUser;

public class EmpListAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	private IDeptService deptService;
	
	private Integer deptid;
	private List<UUser> emplist;
	private static final Integer PAGECOUNT = 2;
	private Integer page =1;
	private Integer endpage;
	private Integer rowCount;

	public String execute(){
		System.out.println(deptid+"+++++++++++");
		rowCount = deptService.countUUser(deptid);
        endpage =((rowCount%PAGECOUNT)==0?(rowCount/PAGECOUNT):(rowCount/PAGECOUNT + 1));
		
		if(page < 0){
			page = 1;
		}
		if(page > endpage){
			page = endpage;
		}
		int start = (int)((page - 1)*PAGECOUNT - 1);
		emplist = deptService.empList(deptid);
		return "success";
	}

	public IDeptService getDeptService() {
		return deptService;
	}

	public void setDeptService(IDeptService deptService) {
		this.deptService = deptService;
	}

	public Integer getDeptid() {
		return deptid;
	}

	public void setDeptid(Integer deptid) {
		this.deptid = deptid;
	}

	public List<UUser> getEmplist() {
		return emplist;
	}

	public void setEmplist(List<UUser> emplist) {
		this.emplist = emplist;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getEndpage() {
		return endpage;
	}

	public void setEndpage(Integer endpage) {
		this.endpage = endpage;
	}

	public Integer getRowCount() {
		return rowCount;
	}

	public void setRowCount(Integer rowCount) {
		this.rowCount = rowCount;
	}
	
	
		
}
